package gameBasicElements;

/**
 * @author Tomasz Wiatrowski
 *
 */
@SuppressWarnings("serial")
public class TorusBoard extends AbstractBoard {
	
	public TorusBoard(int size){
		super(size);
	}
	
	private TorusBoard(AbstractBoard board, Position pos, PlayerColor color){
		super(board, pos, color);
	}
	
	private TorusBoard(AbstractBoard board, Move move){
		super(board, move);
	}
	
	@Override
	public Position[] getNeighbours(Position pos) {
		Position[] res = new Position[4];
		res[0]=new Position((pos.getX()+1)%getSize(), pos.getY());
		res[1]=new Position((pos.getX()+getSize()-1)%getSize(), pos.getY());
		res[2]=new Position(pos.getX(), (pos.getY()+1)%getSize());
		res[3]=new Position(pos.getX(), (pos.getY()+getSize()-1)%getSize());
		return res;
	}
	
	@Override
	public Board update(Move move) {
		return new TorusBoard(this, move);
	}
	
	@Override
	public TorusBoard placeStone(Move move){
		return new TorusBoard(this, move.getPosition(), move.getColor());
	}

}
